#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test of --directory option, with multiple directories and multiple languages.

(rxgettext --version) >/dev/null 2>/dev/null \
  || { echo "Skipping test: rxgettext not found"; Exit 77; }

mkdir c-src1 c-src2 sh-src1 sh-src2 ruby-src1 ruby-src2

cat <<\EOF > c-src1/a.c
gettext("some C message");
EOF

cat <<\EOF > c-src2/b.c
gettext("another C message");
EOF

cat <<\EOF > sh-src1/c.sh
gettext "some Shell message"
EOF

cat <<\EOF > sh-src2/d.sh
gettext "another Shell message"
EOF

cat <<\EOF > ruby-src1/e.rb
gettext("some Ruby message");
EOF

cat <<\EOF > ruby-src2/f.rb
gettext("another Ruby message");
EOF

: ${XGETTEXT=xgettext}
${XGETTEXT} -o xg-16.tmp \
            -D c-src1 -D c-src2 -D sh-src1 -D sh-src2 -D ruby-src1 -D ruby-src2 \
            a.c b.c c.sh d.sh e.rb f.rb 2>xg-16.err
test $? = 0 || { cat xg-16.err; Exit 1; }
func_filter_POT_Creation_Date xg-16.tmp xg-16.pot

cat <<\EOF > xg-16.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: a.c:1
msgid "some C message"
msgstr ""

#: b.c:1
msgid "another C message"
msgstr ""

#: c.sh:1
msgid "some Shell message"
msgstr ""

#: d.sh:1
msgid "another Shell message"
msgstr ""

#: e.rb:1
msgid "some Ruby message"
msgstr ""

#: f.rb:1
msgid "another Ruby message"
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} xg-16.ok xg-16.pot
result=$?

exit $result
